﻿
#region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;

#endregion

namespace MarketPulse.BusinessLogic.Private.StateMachine
{
    internal interface IVisitStateContext
    {
        /// <summary>Method used to set the current state of the state machine.</summary>
        /// <param name="visitState">The new state to become the current state.</param>
        void SetState(IVisitState visitState);

        /// <summary>Method used to set the current state of the state machine.</summary>
        /// <returns>The current state</returns>
        IVisitState GetState();

        /// <summary>
        /// This method interrogates the current internal state to ascertain
        /// if the event in question causes a valid state transition.
        /// </summary>
        /// <param name="eventName">The name of the event (method)</param>
        /// <returns></returns>
        bool CanTransition(string eventName);

        /// <summary>
        /// Method used to assign the Visit to a specific user based on the user guid value supplied
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        /// <param name="userGuid">The Guid of the user to assign this Visit to</param>
        /// <param name="plannedDate">The date the Visit is planned to take place</param>
        bool Assign(bool tryTransition, Guid userGuid, DateTime plannedDate);

        /// <summary>
        /// Method used to unassign the Visit
        /// </summary> 
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        /// <param name="payment">Enumeration variable used to determine whether payment should be honoured</param>               
        bool Unassign(bool tryTransition, Visit.PaymentStatus payment);

        /// <summary>
        /// Method used to release the Visit and make it ready to be assigned
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool Release(bool tryTransition);

        /// <summary>
        /// Method used to save the information for this Visit captured as part of the data entry process
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool StartDataEntry(bool tryTransition);

        /// <summary>
        /// Method used to save the information for this Visit captured as part of the data entry process
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        /// <param name="responses">The XML response set to attach to the survey instance for the Visit</param>
        bool DataEnter(bool tryTransition, XElement responses);

        /// <summary>
        /// Method used to complete the data entry process for this Visit
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool CompleteDataEntry(bool tryTransition);

        /// <summary>
        /// Method used to begin the QA process for this Visit
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAStartDataEntry(bool tryTransition);

        /// <summary>
        /// Method used to enter data during the QA process for this Visit
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QADataEnter(bool tryTransition);

        /// <summary>
        /// Method used to approve the QA of the responses gathered as part of this Visit
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAApprove(bool tryTransition);

        /// <summary>
        /// Method used to fail the QA of the responses gathered as part of this Visit
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAFail(bool tryTransition);

        /// <summary>
        /// Method used to put the QA process on hold whilst other aspects of the Visit are adressed 
        /// (i.e. query from the branch, clarification of an answer by the shopper etc...)
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAPutOnHold(bool tryTransition);

        /// <summary>
        /// Method used to reopen the QA process for this Visit
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool QAReopen(bool tryTransition);

        /// <summary>
        /// Method used to mark this Visit as Ready for Transfer.
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool MarkReadyForTransfer(bool tryTransition);

        /// <summary>
        /// Method used to create a new version of this visit for revisiting.
        /// </summary>
        /// <param name="tryTransition">Whether to simulate or actually perform a transition</param>
        bool Revisit(bool tryTransition);

    }
}
